#ifndef GUI_H
#define GUI_H
#define NOMINMAX

//@author A0101291X
#include <vector>
#include <qstringlist.h>
#include <QtWidgets/QMainWindow>
#include <qtimer.h>
#include "ui_gui.h"
#include "guidialog.h"
#include "ColourScheme.h"
#include "Utilities.h"
#include "Logic.h"
#include "Task.h"

class GUI : public QMainWindow {
	Q_OBJECT

public:
	GUI(QWidget *parent = 0);
	~GUI();

private:
	Ui::GUIClass ui;
	GUIDialog helpDialog;
	QPixmap greenTick;
	QPixmap redCross;
	QTimer *timer;

	static const string CONFIG_FILENAME;
	static const QString MESSAGE_WELCOME;
	static const QString MESSAGE_NO_TASK_TODAY;
	static const QString MESSAGE_INDICATE_TODAY;
	static const QString MESSAGE_INDICATE_SEARCH;
	static const QString MESSAGE_INDICATE_ALL;

	static const QString STRING_F1_HELP;
	static const QString HEADER_NUMBER;
	static const QString HEADER_DESCRIPTION;
	static const QString HEADER_DATE;
	static const QString HEADER_START;
	static const QString HEADER_END;
	static const QString HEADER_TAG;
	static const QString HEADER_DONE;
	
	static enum ColumnHeader {
		TASK_NUMBER, 
		TASK_DESCRIPTION, 
		DATE, 
		START_TIME, 
		END_TIME,
		TAG
	};

	static enum Alignment {
		ALIGN_LEFT,
		ALIGN_CENTER,
	};

	vector<Task> mainDisplay;
	vector<Task> doneDisplay;
	Logic logic;
	ColourScheme themes;
	bool isInputValid;

	fstream configFile;
	int currentTheme;
	bool is24HourFormat;
	bool isDateExpanded;

	// UI setup
	void initialUISetup();
	void setUIComponents();
	void initialiseConfig();
	void initialiseShortcuts();
	void initialiseTimer();

	void readConfigFile();
	void writeConfigFile();

	void setTitle();
	void setDateTime();
	QString UIDate();
	QString UITime();
	void setCommandList();
	void setTaskTable(); 
	void setDoneTable();
	void setStyleSheet();
	void setCompleter();

	void setIconValid();
	void setIconInvalid();
	void setInputAsInvalid();
	void clearValidLabel();

	// Additional Features
	QStringList inputCompleter;
	QCompleter *completer;
	QString setTimeFormat(QString);
	QString setDateFormat(QString);
	void initialiseColourScheme();

	//During program execution
	void welcomeDisplay();
	void updateDisplay();
	void indicateDisplayType();
	void displayFeedback();
	void displayFeedback(QString);
	void updateFeedbackColour();
	void showTasksToUser(); 
	void showDoneToUser();
	void setTaskItem(int, int, QString, Alignment, TaskStatus);
	void setDoneItem(int, int, QString, Alignment);

private slots: 
	void on_commandLine_returnPressed();
	void on_commandLine_textChanged();

	void changeTheme();
	void changeTimePreference();
	void changeDatePreference();
	void moveCursor();

	void helpFunction();

	void refreshDisplay();
};

#endif // GUI_H
